<div id=dev_track_list>
<?php 

function dev_type($i) {
	switch ($i) {
		case 0:
        	return "Bug";
        	break;
		case 1:
        	return "Mod";
        	break;
	}
	
}

function dev_status ($id, $i) {
	$statii = array(0 => "New", 1 => "In Hand", 2 => "Completed");
	$v = 0;
	$select =  "<select id=dev_status_{$id}>";
	foreach ($statii as $status) {
		$select .= "<option value={$v}";
		if ($i==$v) $select .= " selected ";
		$select .= ">{$status}";
		$v++;
	}
	$select .= "</select>";
	
	
	return $select;
	
}

function get_dev_class($i) {
	
	switch ($i) {
		case 0:
        	return "new";
        	break;
		case 1:
        	return "pending";
        	break;
        case 2:
        	return "completed";
        	break;
	}
}



$count=0;
chdir("../activities");
$d = dir(".");
while (false !== ($entry = $d->read())) {
	if (substr_count($entry,"_details.txt")>0) {
   $count++;
	}
}

for ($i=$count;$i>0;$i--) {
	$status = @file_get_contents("{$i}_status.txt");
	echo "<div class=\"clear_both " . get_dev_class($status) . "\">";
	
	echo "<div>{$i}</div>";
	
	
	
	
	echo "<div>" . dev_type(@file_get_contents("{$i}_type.txt")) . "</div>\n";
	echo "<div>" . @file_get_contents("{$i}_started.txt") . "</div>";
	echo "<div>" . @file_get_contents("{$i}_owner.txt") . "</div>";
	echo "<div>" .  @file_get_contents("{$i}_updated.txt") . "</div>";
	echo "<div>" . @file_get_contents("{$i}_developer.txt") . "</div>";
	echo "<div>" . dev_status($i, $status) . "</div>";
	echo "<div class=dev_details_{$i}>" . file_get_contents("{$i}_details.txt") . "</div>";
	echo "<div>Files:<br><textarea id=dev_files_{$i}>" . @file_get_contents("{$i}_files.txt") . "</textarea></div>";
	echo "<div>Comments:<pre>" . @file_get_contents("{$i}_comments.txt") . "</pre><textarea id=dev_comments_{$i}></textarea></div>";
	echo "<div><button onclick=\"dev_update({$i});\">Update</button><div id=dev_update_result></div></div>";
	echo "</div>";
	
}

?>
</div>